<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>其他辖区单位党建动态信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/win_center.js"></script>
<script type="text/javascript" src="/djzx/js/layer/layer.js" ></script>
<SCRIPT language=JavaScript type=text/JavaScript>
//查询模式：0代表查询，1代表高级查询
var queryMode = 0;
//党建动态查询参数字符串
var activityParamStr = "partyActivity.partyName=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.activityName=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.activityType=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.activityDate=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.address=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.attendNum=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.content=" + encodeURI(encodeURI(""));
activityParamStr += "&partyActivity.situation=" + encodeURI(encodeURI(""));

var partyName_layer = "";
var activityName_layer = "";
var activityType_layer = "";
var activityDate_layer = "";
var address_layer = "";
var attendNum_layer = "";
var content_layer = "";
var situation_layer = "";

window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
}

function delPartyActivity(timeKey){
	var r = confirm("确定要删除吗?");
	if(r){
		$.post(
				"/djzx/OtherPartyActivityAction!delPartyActivity.action",
				{
					"partyActivity.timeKey":timeKey
				},
				function(data){
					alert(data.message);
					if(data.success){
						location.href="/djzx/OtherPartyActivityAction!getPartyActivityListForPage.action";
					}
				},
				"json"
				)
	}
}

function toAddPartyActivity(){
	window.location.href="/djzx/OtherPartyActivityAction!toAddPartyActivity.action";
}

function toEditPartyActivity(timeKey){
	window.location.href="/djzx/OtherPartyActivityAction!toEditPartyActivity.action?partyActivity.timeKey=" + timeKey + "&editFrom=1";
}

function searchPartyActivity(){
	queryMode = 0;
	ajaxPartyActivity(1);
}

function firstPage(){
	ajaxPartyActivity(1);
}

function prevPage(){
	var start =parseInt($("#start").html());
	if(start <= 1){
		start = 1;
	}else{
		start--;
	}
	ajaxPartyActivity(start);
}

function nextPage(){
	var start =parseInt($("#start").html());
	var count = parseInt($("#pageCount").html());
	if(start >= count){
		start = count;
	}else{
		start++;
	}
	ajaxPartyActivity(start);
}

function endPage(){
	var last = parseInt($("#pageCount").html());
	ajaxPartyActivity(last);
}

function ajaxPartyActivity(start){
	var partyName = "";
	var activityName = "";
	var activityType = "";
	var activityDate = "";
	var address = "";
	var attendNum = "";
	var content = "";
	var situation = "";
	
	if(queryMode == 0){ // 查询
		var param = $.trim($('#param').val());
		var paramValue = $.trim($('#paramValue').val());
		
		if(param == 'partyName'){
			partyName = paramValue;
		}else if(param == 'activityName'){
			activityName = paramValue;
		}else if(param == 'activityType'){
			activityType = paramValue;
		}else if(param == 'activityDate'){
			activityDate = paramValue;
		}else if(param == 'address'){
			address = paramValue;
		}else if(param == 'attendNum'){
			if(isNaN(paramValue) || paramValue == ''){
				alert("请输入数字！");
				return false;
			}
			attendNum = parseInt(paramValue);
		}
	}else if(queryMode == 1){ // 高级查询
		partyName = partyName_layer;
		activityName = activityName_layer;
		activityType = activityType_layer;
		activityDate = activityDate_layer;
		address = address_layer;
		attendNum = attendNum_layer;
		content = content_layer;
		situation = situation_layer;
	}
	
	activityParamStr = "partyActivity.partyName=" + encodeURI(encodeURI(partyName));
	activityParamStr += "&partyActivity.activityName=" + encodeURI(encodeURI(activityName));
	activityParamStr += "&partyActivity.activityType=" + encodeURI(encodeURI(activityType));
	activityParamStr += "&partyActivity.activityDate=" + encodeURI(encodeURI(activityDate));
	activityParamStr += "&partyActivity.address=" + encodeURI(encodeURI(address));
	activityParamStr += "&partyActivity.attendNum=" + encodeURI(encodeURI(attendNum));
	activityParamStr += "&partyActivity.content=" + encodeURI(encodeURI(content));
	activityParamStr += "&partyActivity.situation=" + encodeURI(encodeURI(situation));
	
	$.ajax({
		url:'${pageContext.request.contextPath}/OtherPartyActivityAction!searchPartyActivityList.action',
		data:{
			"page.currPage":start,
			"partyActivity.partyName":partyName,
			"partyActivity.activityName":activityName,
			"partyActivity.activityType":activityType,
			"partyActivity.activityDate":activityDate,
			"partyActivity.address":address,
			"partyActivity.attendNum":attendNum,
			"partyActivity.content":content,
			"partyActivity.situation":situation
		},
		type:'post',
		dataType:'json',
		success:function(data){
			var str="";
			if(data.map.length>0){
				$.each(data.map,function(i){
					str+='<tr><td class="td_01">'+data.map[i].index+
					'</td><td class="td_01"><a href="/djzx/OtherPartyActivityAction!toShowPartyActivity.action?partyActivity.timeKey='+data.map[i].timeKey+'" target="_blank">'+data.map[i].activityName+'</a>'+
					'</td><td class="td_01">'+data.map[i].partyName+
					'</td><td class="td_01">'+data.map[i].activityType+
					'</td><td class="td_01">'+data.map[i].activityDate+
					'</td><td class="td_01">'+data.map[i].address+
					'</td><td class="td_01">'+data.map[i].attendNum+
					'</td><td nowrap class="td_01"><a href="/djzx/OtherPartyActivityAction!toShowPartyActivity.action?partyActivity.timeKey='+data.map[i].timeKey+'" target="_blank">查看</a>|<a href="javascript:void(0)" onclick="toEditPartyActivity('+data.map[i].timeKey+')">编辑</a>|<a href="javascript:void(0)" onclick="delPartyActivity('+data.map[i].timeKey+')">删除</a></td></tr>';
				});
			}
			$("#nodeContent").html(str);
			$("#start").html(data.object.currPage);
			$("#pageCount").html(data.object.pageCount);
			$("#count").html(data.object.count);
		}
	}); 
}

function advancedQueryPartyActivity(){
	queryMode = 1;
	partyName_layer = $.trim($('#partyName').val());
	activityName_layer = $.trim($('#activityName').val());
	activityType_layer = $.trim($('#activityType').val());
	activityDate_layer = $.trim($('#activityDate').val());
	address_layer = $.trim($('#address').val());
	attendNum_layer = $.trim($('#attendNum').val());
	content_layer = $.trim($('#content').val());
	situation_layer = $.trim($('#situation').val());
	ajaxPartyActivity(1);
}

function exportPartyActivityList(){
	//location.href="/djzx/OtherPartyActivityAction!exportPartyActivityListToExcel.action";
	
	var count = parseInt($('#count').html());
	if(count > 0){
		location.href = "/djzx/OtherPartyActivityAction!exportPartyActivityListToExcel.action?" + activityParamStr; 
	}else{
		alert('当前没有党建动态信息');
	}
}

</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input id="flag" value="${flag }" type="hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">党建动态查询</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td_page">
	   查询参数：
      <select name="param" id="param">
      	<option value="partyName">党组织名称</option>
        <option value="activityName">活动名称</option>
        <option value="activityType">活动类型</option>
        <option value="activityDate">活动日期</option>
        <option value="address">活动地址</option>
        <option value="attendNum">参加人数</option>
      </select>
             参数值：
      <input name="paramValue" id="paramValue" type="text" class="input" size="10">
      <input type="button" class="buttonface02" value=" 查询 " onclick="searchPartyActivity()">
      <input type="button" class="buttonface02" value=" 高级查询 " id="advancedQuery">
	  <input type="button" class="buttonface02" value=" 新增 " onclick="toAddPartyActivity()">
	  <input type="button" class="buttonface02" value=" 导出Excel " onclick="exportPartyActivityList()">
    </td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">活动名称</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">活动类型</td>
    <td nowrap class="td_top">日期</td>
    <td nowrap class="td_top">活动地点</td>
     <td nowrap class="td_top">参加人数</td>
	 <td nowrap class="td_top">操作</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="partyActivityList" var="p" status="statu">
  <tr> 
    <td class="td_01">${statu.index+1 }</td>
    <td class="td_01">
    	<a href="/djzx/OtherPartyActivityAction!toShowPartyActivity.action?partyActivity.timeKey=${p.timeKey}" target="_blank">${p.activityName }</a>
    </td>
    <td class="td_01">${p.partyName }</td>
    <td class="td_01">${p.activityType }</td>
    <td class="td_01">${p.activityDate }</td>
    <td class="td_01">${p.address }</td>
	<td class="td_01">${p.attendNum }</td>
	<td nowrap class="td_01">
		<a href="/djzx/OtherPartyActivityAction!toShowPartyActivity.action?partyActivity.timeKey=${p.timeKey}" target="_blank">查看</a>|
		<a href="#" onclick="toEditPartyActivity(${p.timeKey})">编辑</a>|
		<a href="#" onclick="delPartyActivity(${p.timeKey })">删除</a>
	</td>
  </tr>
  </s:iterator>
  </tbody>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap width="95%" class="td_top"></td>
  </tr>
</table>
<table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
  <tr>
    <td height="30" align="right">
	    <img src="/djzx/images/1.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="firstPage()">首页</a>　
	    <img src="/djzx/images/2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="prevPage()">上一页</a>　 
	    <img src="/djzx/images/2-2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="nextPage()">下一页</a>　 
	    <img src="/djzx/images/3.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="endPage()">末页</a>　　
	         当前第<span id="start">${page.currPage}</span>页,共<span id="pageCount">${page.pageCount}</span>页,共<span id="count">${page.count}</span>条记录
    </td>
  </tr>
</table>
<script type="text/javascript">
$(document).ready(function(){
	var layerW = '800px';
	var layerH = '400px';
	   
	// 高级查询界面
	$('#advancedQuery').on('click', function(){ 
		var content = '<br><table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">'
				+ '<tr><td width="90" height="24" class="td_form01">党组织名称</td>' 
				+ '<td nowrap class=td_form02><input type="text" size="30" id="partyName" /></td>'
				+ '<td width="90" class="td_form01">活动名称</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="activityName" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">活动类型</td>'
        		+ '<td nowrap class=td_form02><select name="activityType" id="activityType"><option value=""></option><option value="公益类">公益类</option><option value="服务类">服务类</option><option value="其他">其他</option></select></td>'
        		+ '<td class="td_form01">活动日期</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="activityDate" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">活动地点</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="address" /></td>'
      			+ '<td class="td_form01">参加人数</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="attendNum" /></td></tr>'
      			+ '<tr><td class="td_form01">活动内容</td>'
      			+ '<td nowrap class=td_form02 colspan="3"><textarea style="width:300px;height:100px" name="content" id="content"></textarea></td></tr>'
      			+ '<tr><td class="td_form01">活动情况</td>'
      			+ '<td nowrap class=td_form02 colspan="3"><textarea style="width:300px;height:100px" name="situation" id="situation"></textarea></td></tr></table>'
      			+ '<br><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">'
      			+ '<tr><td align="center"><input name="Submit2" type="submit" class="buttonface" value="  查询  " onClick="advancedQueryPartyActivity()"></td></tr></table>';

		// 页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
		layer.ready(function(){ 
			//官网欢迎页
			layer.open({
				type: 1,
				//skin: 'layui-layer-lan',
				title: '高级查询',
				fix: false,
				shadeClose: true,
				maxmin: true,
				area: [layerW, layerH],
				content: content,
				end: function(){
					//layer.tips('试试相册模块？', '#photosDemo', {tips: 1})
				}
			});
		});
	});
});
</script>
</body>
</html>
